define([
        'app/utils/WebUtils',
        'app/utils/WeixinUtils',
        'text!app/tpl/createRoom.html',

        'app/service/RoomService',

        'app/directive/CreateRoomDirective'

        
        ], function (
        WebUtils,
        WeixinUtils,
        createRoomTpl,

        RoomService,

        CreateRoomDirective
    ) {  

    var controller = function (orgUuid) {

        //0. Weixin Disabled
        WeixinUtils.disableAll();

        
        //1. Data Initialized
        if($.isNull($.getHashUrlParam("unionid"))){
            $.redirectTo($.wjtBaseBackend + "/mvc/authorize?state=login");
            return;
        }

        //2. Weixin Initialized
        WeixinUtils.disableAll();

        //3. tpl Initialized - Never change!!!
        var tpl = WebUtils.tplInitialized();

        //4. UI Initialized
        var createRoomUI = _.template(createRoomTpl)({
            "orguuid": orgUuid
        });
       

        //4. Assemble
        tpl.append(createRoomUI);

        //5. Render - Never change!!!
        WebUtils.render(tpl);

        //6. Directive initialized
        CreateRoomDirective.directive_createRoom();
        CreateRoomDirective.directive_datetimepickerInit();      
        CreateRoomDirective.directive_inputname();
        CreateRoomDirective.directive_inputfee();
        CreateRoomDirective.directive_inputpwd();


        //7. routechange - Never change!!!
        controller.onRouteChange = WebUtils.routeChange;

    };

    return controller;


});
